import exec from '../db/connectMysql'
class video{
  protected id!:number;
  protected name!:string;
  protected from!:number;
  protected size!:number
  protected currentCount!:string
  protected category!:string
  // constructor(id?:number,name?:string,city?:string,count?:string,category?:string,year?:number
  //   ,descript?:string,img?:string,video?:string,currentCount?:string,from?:string,size?:string){
  //   if(id)this.id=id;
  //   if(name)this.name=name;
  //   if(count)this.count = count
  //   if(category)this.category = category
  //   if(from)this.from = from
  //   if(size)this.size = size
  // }
  //分页查询
  search(){
    let sql = `select Name,img from dongman group by Name,img limit ?,?`
    let arr = [this.from,this.size]
    return exec(sql,arr)
  }
  watch(){
    let sql = `select * from dongman where id = ?`
    let arr = [this.id]
    return exec(sql,arr)
  }
  del(){
    let sql = `delete from dongman where id = ?`
    let arr = [this.id]
    return exec(sql,arr)
  }
  filterForCategory(){
    let sql = `select Name,img from dongman where category like '%${this.category}%'  group by Name,img limit ?,?`
    let arr = [this.from,this.size]
    return exec(sql,arr)
  }
  filterForName(){
    let sql = `select * from dongman where Name = ?`
    let arr = [this.name]
    return exec(sql,arr)
  }
  filterForCurrentCount(){
    let sql = `select * from dongman where Name = ? and currentCount = ?`
    let arr = [this.name,this.currentCount]
    return exec(sql,arr)
  }
}
class searchAllVideo extends video{
  constructor(from:number,size:number){
    super()
    this.from = from
    this.size = size
  }
}
class delVideo extends video{
  constructor(id:number){
    super()
    this.id = id
  }
}
class filterCategoryVideo extends video{
  constructor(category:string,from:number,size:number){
    super()
    this.category = category
    this.from = from
    this.size = size
  }
}
class filterNameVideo extends video{
  constructor(name:string){
    super()
    this.name = name
  }
}
class filterCurrentCountVideo extends video{
  constructor(currentCount:string,name:string){
    super()
    this.name = name
    this.currentCount = currentCount
  }
}
export default {searchAllVideo,delVideo,filterCategoryVideo,filterNameVideo,filterCurrentCountVideo}